home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Information / Digests / CSMP Digest / volume 1 / csmp-v1-169.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  49.5 KB  |  1,274 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Tue, 18 Aug 92       Volume 1 : Issue 169
  2.  
  3. Today's Topics:
  4.  
  5.     Help! Stack overwriting heap!
  6.     Microcode (was Re: Does the 68000 have a "block move" instruction)
  7.     List Manager help sought
  8.  
  9.  
  10.  
  11. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  12.  
  13. The digest is a collection of article threads from the internet newsgroup
  14. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  15. regularly and want an archive of the discussions.  If you don't know what a
  16. newsgroup is, you probably don't have access to it.  Ask your systems
  17. administrator(s) for details.  (This means you can't post questions to the
  18. digest.)
  19.  
  20. Each issue of the digest contains one or more sets of articles (called
  21. threads), with each set corresponding to a 'discussion' of a particular
  22. subject.  The articles are not edited; all articles included in this digest
  23. are in their original posted form (as received by our news server at
  24. cs.uoregon.edu).  Article threads are not added to the digest until the last
  25. article added to the thread is at least one month old (this is to ensure that
  26. the thread is dead before adding it to the digest).  Article threads that
  27. consist of only one message are generally not included in the digest.
  28.  
  29. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  30. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  31. file /pub/mac/csmp-digest/README before downloading any files.  The most
  32. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  33. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  34. archive has a mail server; send a message with the text '$MACarch help' (no
  35. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  36.  
  37. The digest is also available via email.  Just send a note saying that you
  38. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  39. automatically receive each new issue as it is created.  Sorry, back issues
  40. are not available through the mailing list.
  41.  
  42. Send administrative mail to mkelly@cs.uoregon.edu.
  43.  
  44.  
  45. -------------------------------------------------------
  46.  
  47. From: u2005681@ucsvc.ucs.unimelb.edu.au
  48. Subject: Help! Stack overwriting heap!
  49. Date: 15 Jul 92 10:45:32 GMT
  50. Organization: The University of Melbourne
  51.  
  52. Hi people,
  53. I am manipulating a large array (six dimensional) of structs (containing
  54. 8 float numbers) using THINK C 5.0.2. The program runs fine on our SGI
  55. workstation but on the Mac I get a message that the stack is overwriting
  56. the heap (this has an interesting effect on the stability of the MacOS).
  57. What can I do and how do I increase the stack size?
  58.  
  59. Thank you in advance
  60. Chris Hofflin
  61.  
  62. +++++++++++++++++++++++++++
  63.  
  64. From: mlanett@Apple.COM (Mark Lanett)
  65. Date: 15 Jul 92 11:57:03 GMT
  66. Organization: Apple Computer Inc., Cupertino, CA
  67.  
  68. u2005681@ucsvc.ucs.unimelb.edu.au writes:
  69.  
  70. >Hi people,
  71. >I am manipulating a large array (six dimensional) of structs (containing
  72. >8 float numbers) using THINK C 5.0.2. The program runs fine on our SGI
  73. >workstation but on the Mac I get a message that the stack is overwriting
  74. >the heap (this has an interesting effect on the stability of the MacOS).
  75. >What can I do and how do I increase the stack size?
  76.  
  77. Unless your matrix is very small, I doubt it'll fit on the stack. So my guess 
  78. is that it's on the heap, and so has nothing whatsoever to do with a
  79. stack overflow. The best way to cause a stack overflow is just to make a
  80. programming error that causes an endless recursion somewhere (for example,
  81. leaving off inherited:: in C++. But I digress). Why this would occur on the
  82. Mac and not SGI could be due to any number of reasons.
  83.  
  84. Now, if your matrix really is on the stack, I could see problems. But you say
  85. the *same* program is running on an SGI and Mac, which makes me think you've
  86. got it under MPW. And MPW gives lots (at least 128K) of stack space to its
  87. tools.
  88.  
  89. Well anyway, you haven't said enough for me to not make these assumptions (wild
  90. guesses, whatever). How about a little more background?
  91. - -- 
  92. Have a bajillion brilliant Jobsian lithium licks.
  93. Mark Lanett, NOT speaking for apple. Personal opinion only.
  94.  
  95. +++++++++++++++++++++++++++
  96.  
  97. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  98. Date: 15 Jul 92 14:39:21 GMT
  99. Organization: Symantec Corp.
  100.  
  101. In article <70049@apple.Apple.COM> mlanett@Apple.COM (Mark Lanett) writes:
  102.  
  103.    u2005681@ucsvc.ucs.unimelb.edu.au writes:
  104.  
  105.    >Hi people,
  106.    >I am manipulating a large array (six dimensional) of structs (containing
  107.    >8 float numbers) using THINK C 5.0.2. The program runs fine on our SGI
  108.    >workstation but on the Mac I get a message that the stack is overwriting
  109.    >the heap (this has an interesting effect on the stability of the MacOS).
  110.    >What can I do and how do I increase the stack size?
  111.  
  112.    Unless your matrix is very small, I doubt it'll fit on the stack.
  113.    So my guess is that it's on the heap, and so has nothing whatsoever
  114.    to do with a stack overflow.
  115.  
  116. Actually, THINK C 5.0 supports automatics of virtually any size. If
  117. you like, you can declare local variables that are, say, 128K in size.
  118. However, you're limited to the default stack size on your Mac. On a
  119. machine with Color Quickdraw, you'll get a 24K stack, on all others
  120. you'll get an 8K stack. If you want to grow your stack, you should use
  121. a routine like:
  122.  
  123.     void GrowStack(long needed)   // needed is how much space we want
  124.     {
  125.         SetApplLimit(GetApplLimit() - (needed - StackSpace()));
  126.         MaxApplZone();
  127.     }
  128.  
  129. You must call this routine at the start of your program, before using
  130. any of the standard I/O routines.
  131.  
  132.    But you say the *same* program is running on an SGI and Mac, which
  133.    makes me think you've got it under MPW.
  134.  
  135. Now what's *that* supposed to mean ??
  136.  
  137.     -phil
  138. - --
  139.    Phil Shapiro                                   Software Engineer
  140.    Language Products Group                     Symantec Corporation
  141.            Internet: phils@cs.brandeis.edu
  142.  
  143. +++++++++++++++++++++++++++
  144.  
  145. From: mlanett@Apple.COM (Mark Lanett)
  146. Date: 15 Jul 92 14:53:03 GMT
  147. Organization: Apple Computer Inc., Cupertino, CA
  148.  
  149. phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
  150.  
  151. >In article <70049@apple.Apple.COM> mlanett@Apple.COM (Mark Lanett (me)) writes:
  152.  
  153. >   u2005681@ucsvc.ucs.unimelb.edu.au writes:
  154.  
  155. >   >Hi people,
  156. >   >I am manipulating a large array (six dimensional) of structs (containing
  157. >   >8 float numbers) using THINK C 5.0.2. The program runs fine on our SGI...
  158.  
  159. >   But you say the *same* program is running on an SGI and Mac, which
  160. >   makes me think you've got it under MPW.
  161.  
  162. >Now what's *that* supposed to mean ??
  163.  
  164. Never mind. End of the day non-thinkingness. Does TC have a stdio mode? Yes,
  165. I know. Hmmm, does it have a curses lib? Yes, we do have it site-licensed, I
  166. just haven't used it since I started programming the Mac, when it was
  167. LightSpeed 2.0.
  168. - -- 
  169. Have a bajillion brilliant Jobsian lithium licks.
  170. Mark Lanett, NOT speaking for apple. Personal opinion only.
  171.  
  172. ---------------------------
  173.  
  174. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  175. Subject: Microcode (was Re: Does the 68000 have a "block move" instruction)
  176. Organization: Kalamazoo College
  177. Date: Tue, 23 Jun 1992 12:36:39 GMT
  178.  
  179. neeri@iis.ethz.ch (Matthias Neeracher) writes:
  180. >cramer@unixland.natick.ma.us (Bill Cramer) writes:
  181. >>
  182. >>As someone else
  183. >>noted, on a 68020 or later processor, these instructions stay in 
  184. >>the instruction cache, so it gives you the same (or better) speed
  185. >>as a block move instruction without the microcode penalty. 
  186. >
  187. >While it is true that you would have to pay a performance penalty by having a
  188. >blockmove instruction, I'd like to point out that, as far as I know, the 680X0
  189. >family *is* microcoded, and the instruction cache doesn't cache microcode.
  190.  
  191. I think what Bill meant by "microcode penalty" was that adding "funny
  192. instructions" like a blockmove adds microcode to the processor, and in
  193. general, the more transistors you have, the slower the chip.
  194.  
  195. I wouldn't think there are any modern-day processors that don't use
  196. microcode, are there?
  197. - -- 
  198.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  199.  Never piss off a computer.
  200.  
  201. +++++++++++++++++++++++++++
  202.  
  203. From: palmer@cco.caltech.edu (David Palmer)
  204. Organization: California Institute of Technology, Pasadena
  205. Date: Tue, 23 Jun 1992 13:17:16 GMT
  206.  
  207. k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  208.  
  209. >neeri@iis.ethz.ch (Matthias Neeracher) writes:
  210. >>cramer@unixland.natick.ma.us (Bill Cramer) writes:
  211. >>>
  212. >>>As someone else
  213. >>>noted, on a 68020 or later processor, these instructions stay in 
  214. >>>the instruction cache, so it gives you the same (or better) speed
  215. >>>as a block move instruction without the microcode penalty. 
  216. >>
  217. >>While it is true that you would have to pay a performance penalty by having a
  218. >>blockmove instruction, I'd like to point out that, as far as I know, the 680X0
  219. >>family *is* microcoded, and the instruction cache doesn't cache microcode.
  220.  
  221. >I think what Bill meant by "microcode penalty" was that adding "funny
  222. >instructions" like a blockmove adds microcode to the processor, and in
  223. >general, the more transistors you have, the slower the chip.
  224.  
  225. >I wouldn't think there are any modern-day processors that don't use
  226. >microcode, are there?
  227.  
  228. I think that RISC processors might not have microcode as such.  (A
  229. single clock cycle isn't enough time to execute many microcode
  230. instructions.)
  231.  
  232. On a historical note, the original VAX 780 (the Complex Instruction
  233. Set Computer that convinced people that RISC was the way to go :-)
  234. had an instruction (I think it was a string compare) which, in
  235. the first release of the microcode, was actually slower than
  236. a short assembly language routine which did not use that instruction.
  237. (I learned about this back in ~1983 so it is not apocryphal.)
  238.  
  239. - -- 
  240.         David Palmer         palmer@tgrs.gsfc.nasa.gov
  241. I am now at Goddard Space Flight Center/NASA, for whom I do not speak.
  242.  
  243. +++++++++++++++++++++++++++
  244.  
  245. From: stu5s11@bcrka280.bnr.ca
  246. Date: 23 Jun 92 21:21:01 GMT
  247. Organization: Bell-Northern Research, Ottawa, Canada
  248.  
  249.  
  250. >I think what Bill meant by "microcode penalty" was that adding "funny
  251. >instructions" like a blockmove adds microcode to the processor, and in
  252. >general, the more transistors you have, the slower the chip.
  253. >
  254. >I wouldn't think there are any modern-day processors that don't use
  255. >microcode, are there?
  256.  
  257. Based on what I've heard microcode, is not only on it's way out,
  258. it's long gone. I believe that the 68040 uses microcode only in
  259. limited amounts, or not at all.
  260.  
  261. The problem is that microcoding adds another layer of depth,
  262. causing additional delays.  This means you can't crank up
  263. the speed of the processor clock.  This probably has something
  264. to do with the fact that 68000's only go up to 16 Mhz, while
  265. 68030's are availible up to 50Mhz.  Certainly no one is using 
  266. nanocode, like the original 68000 does.
  267.  
  268. This is the reason for the popularity of RISC.  Getting rid of
  269. Complex instructions allowed you to get rid of microcode, and
  270. hardwire everything instead. With out the extra delays,
  271. you could crank up the processor speed. Even if emulating a
  272. complex instruction in software took 20% longer, you made it
  273. up with a 30%+ increase in clock speed.
  274.  
  275. +++++++++++++++++++++++++++
  276.  
  277. From: Bruce.Hoult@bbs.actrix.gen.nz
  278. Organization: Actrix Information Exchange
  279. Date: Wed, 24 Jun 1992 08:16:08 GMT
  280.  
  281. In article <1992Jun23.123639.21474@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  282. > I wouldn't think there are any modern-day processors that don't use
  283. > microcode, are there?
  284.  
  285. Every RISC processor, perhaps?  :-)   Even the 68040 in my Quadra 700
  286. can't reply much on microcode, since in a couple of tests I've made
  287. it's managed around 20 MIPS from a 25 MHz clock.  (If there was a 50
  288. MHz or 100 MHz version of the '040 it would be a seriously respectable
  289. chip.  OTOH, no doubt the CISC nature of the instruction set is
  290. exactly *why* there isn't a 100 MHz version :-(  )
  291.  
  292. - -- 
  293. Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  294. BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  295. "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  296. hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  297.  
  298. +++++++++++++++++++++++++++
  299.  
  300. From: Bruce.Hoult@bbs.actrix.gen.nz
  301. Date: Wed, 24 Jun 1992 08:46:50 GMT
  302. Organization: Actrix Information Exchange
  303.  
  304. In article <1992Jun23.131716.25812@cco.caltech.edu> palmer@cco.caltech.edu (David Palmer) writes:
  305. > On a historical note, the original VAX 780 (the Complex Instruction
  306. > Set Computer that convinced people that RISC was the way to go :-)
  307. > had an instruction (I think it was a string compare) which, in
  308. > the first release of the microcode, was actually slower than
  309. > a short assembly language routine which did not use that instruction.
  310. > (I learned about this back in ~1983 so it is not apocryphal.)
  311.  
  312. I think there were many instruction on the 11/780 for which that was true.
  313.  
  314. And it's not just the VAX -- the same thing happens on the 68000. Just
  315. look at MOVEM.W (An)+,[some registers] with a timing of 12 + 4n cycles
  316. (where n is the number of registers loaded).  A simple MOVE.W (An)+,Rn takes
  317. 8 cycles. That means that for one or two registers it's faster to use
  318. the cimple instructions, and for three it's a tie.
  319.  
  320. Or look at the shift instructions.  ASL.W #count,Dn takes 6 + 2n cycles
  321. and ADD.W Dn,Dn takes 4 cycles.  That means that...
  322.  
  323. ADD.W  D2,D2
  324. ADD.W  D2,D2
  325.  
  326. ... is faster than ...
  327.  
  328. ASL.W #2,D2
  329.  
  330.  
  331. The same thing applys to the multiply instruction. Suppose you want to
  332. multiply an unsigned integer by 100 (decimal) which is 1100100 in binary.
  333. You can use...
  334.  
  335. #operand is in D2
  336. ADD.W D2,D2
  337. ADD.W D2,D2
  338. MOVE.W D2,D3
  339. ADD.W D2,D2
  340. ADD.W D2,D2
  341. ADD.W D2,D3
  342. ADD.W D2,D2
  343. ADD.W D3,D2
  344. #operand*100 is in D2
  345.  
  346. ...which is 7 ADD.W's @4 cycles each plus a MOVE.W @4 cycles for a
  347. total of 32 cycles, instead of
  348.  
  349. MULU.W #100,D2
  350.  
  351. ... at 38 + 2n (n is number of 1 bits = 3) + 4 (for the immediate
  352. operand) for a total of 48 clocks.
  353.  
  354. The eight instruction sequence is 50% faster than the multiply instruction!
  355.  
  356. (All timings are for the original 68000)
  357.  
  358. - -- 
  359. Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  360. BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  361. "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  362. hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  363.  
  364. +++++++++++++++++++++++++++
  365.  
  366. From: stu5s11@bcrka280.bnr.ca
  367. Date: 24 Jun 92 16:50:20 GMT
  368. Organization: Bell-Northern Research, Ottawa, Canada
  369.  
  370. >Every RISC processor, perhaps?  :-)   Even the 68040 in my Quadra 700
  371. >can't reply much on microcode, since in a couple of tests I've made
  372. >it's managed around 20 MIPS from a 25 MHz clock.  (If there was a 50
  373. >MHz or 100 MHz version of the '040 it would be a seriously respectable
  374. >chip.  OTOH, no doubt the CISC nature of the instruction set is
  375. >exactly *why* there isn't a 100 MHz version :-(  )
  376. >
  377. >-- 
  378. >Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  379. >BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  380. >"Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  381. >hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  382.  
  383.  
  384. I'd just point out that that the 68040 has two frequencies. The one that
  385. is always mentioned is the Bus Clock (BCLK) which run at either 
  386. 25 Mhz or 33 Mhz. There is another clock called the Processor clock (PCLK)
  387. that runs at double the frequency of the BCLK, ie. 50 Mhz or 66 Mhz. 
  388.  
  389. I'm just pointing this out to show why 68040 speeds seem so low 
  390. compared to 030 speeds. (030s go up to 50Mhz, yet 040s run only
  391. at 25 Mhz. In reality, parts of the 040 are really running at
  392. 50 Mhz.) There really isn't that much potential for a easy 
  393. 50 Mhz (100 Mhz) 68040. Which isn't to say there won't be one, just that
  394. it will pushing the boundaries of IC technology, and not just a tune up.
  395.  
  396. - -------------------------------------------------------------
  397. John Andrusiak
  398.  
  399. +++++++++++++++++++++++++++
  400.  
  401. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  402. Organization: Curtin University of Technology
  403. Date: Thu, 25 Jun 1992 08:48:28 GMT
  404.  
  405. Bruce.Hoult@bbs.actrix.gen.nz writes:
  406.  
  407. >The same thing applys to the multiply instruction. Suppose you want to
  408. >multiply an unsigned integer by 100 (decimal) which is 1100100 in binary.
  409. >You can use...
  410.  
  411. >#operand is in D2
  412. >ADD.W D2,D2
  413. >ADD.W D2,D2
  414. >MOVE.W D2,D3
  415. >ADD.W D2,D2
  416. >ADD.W D2,D2
  417. >ADD.W D2,D3
  418. >ADD.W D2,D2
  419. >ADD.W D3,D2
  420. >#operand*100 is in D2
  421.  
  422. >...which is 7 ADD.W's @4 cycles each plus a MOVE.W @4 cycles for a
  423. >total of 32 cycles, instead of
  424.  
  425. >MULU.W #100,D2
  426.  
  427. >... at 38 + 2n (n is number of 1 bits = 3) + 4 (for the immediate
  428. >operand) for a total of 48 clocks.
  429.  
  430. >The eight instruction sequence is 50% faster than the multiply instruction!
  431.  
  432. Ahh yes, but only one of them calculates D2 * 100 :-)  Now if we were 
  433. interested in D2 * 52, well your logic might work quite well then :-)
  434. I think I'll stick with x:=100*y myself :-)
  435.  
  436. And anyway, the Z80 is better than the 6502 :-)
  437.    Peter.
  438.  
  439.  
  440. +++++++++++++++++++++++++++
  441.  
  442. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  443. Date: 25 Jun 92 08:42:46 GMT
  444. Organization: NCRPDA, Curtin University
  445.  
  446. In article <1992Jun24.084650.1693@actrix.gen.nz>,
  447. Bruce.Hoult@bbs.actrix.gen.nz wrote:
  448.  
  449. > The same thing applys to the multiply instruction. Suppose you want to
  450. > multiply an unsigned integer by 100 (decimal) which is 1100100 in binary.
  451. > You can use...
  452. > #operand is in D2
  453. > ADD.W D2,D2
  454. > ADD.W D2,D2
  455. > MOVE.W D2,D3
  456. > ADD.W D2,D2
  457. > ADD.W D2,D2
  458. > ADD.W D2,D3
  459. > ADD.W D2,D2
  460. > ADD.W D3,D2
  461. > #operand*100 is in D2
  462. > ...which is 7 ADD.W's @4 cycles each plus a MOVE.W @4 cycles for a
  463. > total of 32 cycles, instead of
  464. > MULU.W #100,D2
  465. > ... at 38 + 2n (n is number of 1 bits = 3) + 4 (for the immediate
  466. > operand) for a total of 48 clocks.
  467. > The eight instruction sequence is 50% faster than the multiply instruction!
  468.  
  469. Ahh yes, but only one of them calculates D2 * 100 :-)  Now if we were 
  470. interested in D2 * 52, well your logic might work quite well then :-)
  471.  
  472. And anyway, the Z80 is better than the 6502 :-)
  473.    Peter.
  474.  
  475. +++++++++++++++++++++++++++
  476.  
  477. From: jackb@mdd.comm.mot.com (Jack Brindle)
  478. Date: 25 Jun 92 16:46:06 GMT
  479. Organization: Motorola, Mobile Data Division - Seattle, WA
  480.  
  481. In article <1992Jun25.084828.22882@cujo.curtin.edu.au> peter@cujo.curtin.edu.au (Peter N Lewis) writes:
  482. >
  483. >And anyway, the Z80 is better than the 6502 :-)
  484.  
  485. Gee, I thought this was a Mac forum. But since you brought it up,
  486. the 6502 at the same clock rate bench marks quite a bit faster than
  487. the Z80. A 4MHz 6502 will simply blow away a 4 MHz Z80 (or even an
  488. 8 MHz Z80 for that matter). The 6502 continues to be the most widely
  489. produced 8 bit processor in the world (for about the 14th year in a
  490. row). It is very widely used in single chip versions in all sort of
  491. products; the Mitsubishi versions are used in many Japanese-made
  492. appliances like microwave ovens and such. Amazing that after 17 years
  493. of existance it still holds a commanding lead...
  494.  
  495. Now maybe we can get back to Mac issues. Actually the pertinence of
  496. this topic is the fact that the IIfx contains at least one, if not two
  497. 6502 microcells in its logic, and the fact that the IWM and SWIM are
  498. basically hardware implementations of Apple's 6502 based disk
  499. controller. It's interesting to see the Lisa / Mac-XL's floppy
  500. controller - it is a 6504 implementation of the basic Apple II disk
  501. subsystem!
  502.  
  503. Jack Brindle
  504. ham radio: wa4fib
  505. internet: jackb@mdd.comm.mot.com
  506.  
  507. +++++++++++++++++++++++++++
  508.  
  509. From: Bruce.Hoult@bbs.actrix.gen.nz
  510. Date: Fri, 26 Jun 1992 02:27:35 GMT
  511. Organization: Actrix Information Exchange
  512.  
  513. In article <1992Jun25.084828.22882@cujo.curtin.edu.au> peter@cujo.curtin.edu.au (Peter N Lewis) writes:
  514. > >The eight instruction sequence is 50% faster than the multiply instruction!
  515. > Ahh yes, but only one of them calculates D2 * 100 :-)  Now if we were 
  516. > interested in D2 * 52, well your logic might work quite well then :-)
  517. > I think I'll stick with x:=100*y myself :-)
  518.  
  519. Uh, yeah, I noticed that a while after I posted it.  I was wondering whether
  520. anyone would read closely enough to notice :-)
  521.  
  522. Just include an extra ADD.W (or change the sequence of (now) three
  523. ADD.W's to an ASL.W #3 which takes the same amount of time) and change
  524. the "50% faster" to "33% faster".
  525.  
  526.  
  527. > And anyway, the Z80 is better than the 6502 :-)
  528.  
  529. I once wrote a few algorithms in an optimal manner (or as close as I could
  530. get :-) for both the 6502 and Z80.  The Z80 required about three times as
  531. many clock cycles as the 6502 (and incidentally was much harder to
  532. find the optimal sequence for) which meant that the then common 4 MHz
  533. Z80's were just a little faster than the 1 MHz 6502.
  534.  
  535. Now you can get 10 MHz 6502's.  Where are the 30 MHz Z80's?  :-)
  536.  
  537. - -- 
  538. Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  539. BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  540. "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  541. hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  542.  
  543. +++++++++++++++++++++++++++
  544.  
  545. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  546. Date: 28 Jun 92 23:42:37 GMT
  547. Organization: Royal Institute of Technology, Stockholm, Sweden
  548.  
  549. .kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
  550.  
  551.    >While it is true that you would have to pay a performance penalty by having a
  552.    >blockmove instruction, I'd like to point out that, as far as I know, the 680X0
  553.    >family *is* microcoded, and the instruction cache doesn't cache microcode.
  554.  
  555. Why would it; access time to microcode is (pretty much)
  556. instaneous - at least fast enough for 0 wait cycles which
  557. eliminates the need for microcoding. Usually microcode is
  558. hardwired in the logic, even.
  559.  
  560.    instructions" like a blockmove adds microcode to the processor, and in
  561.    general, the more transistors you have, the slower the chip.
  562.  
  563. Not exactly true. If you have more transistors in SERIES in the
  564. signal path, you get slower chips, However, parallell transistors
  565. like those for caches, or for registers, don't slow things down,
  566. quite the opposite !
  567.  
  568.    I wouldn't think there are any modern-day processors that don't use
  569.    microcode, are there?
  570.  
  571. Yes, basically that's what a CISC chip is, while RISC chips
  572. usually do not rely on microcode. However, how do we classify the
  573. 68040 which executes all basic instructions (add, compare, move
  574. registers, ...) in one cycle, and store instructions in two, just
  575. like a RISC ? It also has a sexy pipeline...
  576.  
  577. Trivia: For the Power chip, a branch (conditional) takes the
  578. whopping amount of 0 cycles to execute (!)
  579.  
  580. - -- 
  581.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  582.  
  583.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  584.                - Andrew Kass in comp.sys.mac.hardware
  585.  
  586. +++++++++++++++++++++++++++
  587.  
  588. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  589. Date: 28 Jun 92 23:47:33 GMT
  590. Organization: Royal Institute of Technology, Stockholm, Sweden
  591.  
  592. .comm.mot.com> jackb@mdd.comm.mot.com (Jack Brindle) writes:
  593.  
  594.    Now maybe we can get back to Mac issues. Actually the pertinence of
  595.    this topic is the fact that the IIfx contains at least one, if not two
  596.    6502 microcells in its logic, and the fact that the IWM and SWIM are
  597.  
  598. Two, as well as the Quadra 900 and 950 (but not 700)
  599.  
  600. - -- 
  601.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  602.  
  603.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  604.                - Andrew Kass in comp.sys.mac.hardware
  605.  
  606. +++++++++++++++++++++++++++
  607.  
  608. From: brad@titan.austin.ibm.com (Brad Garton)
  609. Date: 30 Jun 92 23:42:53 GMT
  610. Organization: IBM Advanced Workstation Division
  611.  
  612. >   >While it is true that you would have to pay a performance penalty
  613. by having a
  614. >   >blockmove instruction, I'd like to point out that, as far as I
  615. know, the 680X0
  616. >   >family *is* microcoded, and the instruction cache doesn't cache microcode.
  617. >(Jon W writes )
  618. >Why would it; access time to microcode is (pretty much)
  619. >instaneous - at least fast enough for 0 wait cycles which
  620. >eliminates the need for microcoding. Usually microcode is
  621. >hardwired in the logic, even.
  622.  
  623.  It IS microcoded and microcode access is NOT instantaneous. Microcode
  624. is more like a ROM that drives control signals for the internal logic of 
  625. the processor, the longer the microcode the longer it takes to decode 
  626. addresses within the microcode ROM and potentially the longer it takes to 
  627. run ALL instructions. This instruction decode time for processors with 
  628. complex instruction sets is one of the reasons why we have RISC processors.
  629. Also instructions like this tend to break pipelines. Maybe someone from 
  630. Motorola can help out on why this is true for the 680x0 family. 
  631.  
  632.  
  633. >>  instructions" like a blockmove adds microcode to the processor, and in
  634. >>   general, the more transistors you have, the slower the chip.
  635.  
  636. >Not exactly true. If you have more transistors in SERIES in the
  637. >signal path, you get slower chips, However, parallell transistors
  638. >like those for caches, or for registers, don't slow things down,
  639. >quite the opposite !
  640.  
  641. Jamie's argument is a good one though. Also this is an optimization problem
  642. you are balancing cost vs function vs reliability. If you trade off a lot 
  643. of transistors for this function you don't have them to do equally valuable 
  644. things OR you wind up with a chip die thats an inch square and costs 3K. 
  645. and the yield is .001 % 
  646.  
  647. >Yes, basically that's what a CISC chip is, while RISC chips
  648. >usually do not rely on microcode. However, how do we classify the
  649.                                              ^^^^^^^^^^^^^^^^^
  650. >68040 which executes all basic instructions (add, compare, move
  651. >registers, ...) in one cycle, and store instructions in two, just
  652. >like a RISC ? It also has a sexy pipeline...
  653.  
  654. As a very competitive processor.   
  655.  
  656.  
  657. >Trivia: For the Power chip, a branch (conditional) takes the
  658. >whopping amount of 0 cycles to execute (!)
  659.  
  660. I wish this were true, it is usuallly, but not always.  I'm nit picking. 
  661. It is still pretty good at guessing the right path. 
  662.  
  663. Brad 
  664. ___________________________________________________________
  665. | Brad Garton  (512) 838-1333 | brad@titan.austin.ibm.com |
  666. | I speak for myself not IBM  | VNET: GARTON AT AUSTIN    |
  667. +---------------------------------------------------------+
  668.  
  669. +++++++++++++++++++++++++++
  670.  
  671. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  672. Organization: Royal Institute of Technology, Stockholm, Sweden
  673. Date: Wed, 1 Jul 1992 10:35:07 GMT
  674.  
  675. .ibm.com> brad@titan.austin.ibm.com (Brad Garton) writes:
  676.  
  677.    [someone writes]
  678.    >   >family *is* microcoded, and the instruction cache doesn't cache microcode.
  679.    >(Jon W writes )
  680.    >Why would it; access time to microcode is (pretty much)
  681.    >instaneous - at least fast enough for 0 wait cycles which
  682.  
  683.     It IS microcoded and microcode access is NOT instantaneous. Microcode
  684.    is more like a ROM that drives control signals for the internal logic of 
  685.  
  686. Microcode ACCESS _IS_ instaneous (enough) so that it would NOT be
  687. necessary to cache the microcode. However, microcode EXECUTION, of
  688. course, takes time, but that's another kettle of yellow sharks
  689. entirely.
  690.  
  691.    run ALL instructions. This instruction decode time for processors with 
  692.    complex instruction sets is one of the reasons why we have RISC processors.
  693.  
  694. RISC throws away microcode entirely. More microcode -> larger
  695. microcode addresses and storage -> more transistors needed, but
  696. not necessarily slower execution since address buses to microcode
  697. (not to be confised with the external address bus) are parallell.
  698. Or do you sincerely believe that an 8 bit bus would be faster ? :-)
  699.  
  700.    Also instructions like this tend to break pipelines. Maybe someone from 
  701.    Motorola can help out on why this is true for the 680x0 family. 
  702.  
  703. As soon as instructions take more than one cycle before the next
  704. instruction start/execute may take place, it leaves bubbles in the
  705. pipeline. That happens on RISC too, with load and store instructions.
  706. (An instruction on an MC68040 actually takes 6 cycles from start to
  707. finish, but since the pipe is six stages, the "normal" instruction
  708. execution time is - 1 cycle !)
  709.  
  710.    >Trivia: For the Power chip, a branch (conditional) takes the
  711.    >whopping amount of 0 cycles to execute (!)
  712.  
  713.    I wish this were true, it is usuallly, but not always.  I'm nit picking. 
  714.    It is still pretty good at guessing the right path. 
  715.  
  716. Yes, and it requires the condition code it needs to be available
  717. a few cycles beforehand, else we get pipeline problems. However,
  718. in a typical non-trivial for or while loop, we actually get a
  719. 0-cycle branch. Nice touch with the 8 "CCR"-s too, to avoid that
  720. bottleneck...
  721.  
  722. - -- 
  723.          Jon W{tte, Svartmangatan 18, S-111 29 Stockholm, Sweden
  724.  
  725.  "Difficult, obscure, incoherent and nonstandard does not imply more power."
  726.                - Andrew Kass in comp.sys.mac.hardware
  727.  
  728. +++++++++++++++++++++++++++
  729.  
  730. From: paul@taniwha.UUCP (Paul Campbell)
  731. Date: 30 Jun 92 15:42:58 GMT
  732. Organization: Taniwha Systems Design
  733.  
  734. >Bruce.Hoult@bbs.actrix.gen.nz writes:
  735.  
  736. >The same thing applys to the multiply instruction. Suppose you want to
  737. >multiply an unsigned integer by 100 (decimal) which is 1100100 in binary.
  738. >You can use...
  739.  
  740. >#operand is in D2
  741. >ADD.W D2,D2
  742. >ADD.W D2,D2
  743. >MOVE.W D2,D3
  744. >ADD.W D2,D2
  745. >ADD.W D2,D2
  746. >ADD.W D2,D3
  747. >ADD.W D2,D2
  748. >ADD.W D3,D2
  749. >#operand*100 is in D2
  750.  
  751. >...which is 7 ADD.W's @4 cycles each plus a MOVE.W @4 cycles for a
  752. >total of 32 cycles, instead of
  753.  
  754. >MULU.W #100,D2
  755.  
  756. >... at 38 + 2n (n is number of 1 bits = 3) + 4 (for the immediate
  757. >operand) for a total of 48 clocks.
  758.  
  759. >The eight instruction sequence is 50% faster than the multiply instruction!
  760.  
  761. But it takes 16 bytes of instructions compared with 4 bytes, the difference
  762. is about a whole cache line, the extra time it takes to read this is about
  763. ~60+3*40+100 (assuming worst case RAS precharge delays) = 280nS which on a
  764. system with a 50MHz cpu core clock (ie a 50MHz '030 or 25MHz '040) is 14 clocks
  765. which makes total execution time for the first case to be 46 clocks, if
  766. it's not in the cache already (ie it's not in an inner loop) - still faster,
  767. but maybe not worth the effort.
  768.  
  769. It also depends on which CPU you use, my '020 manual gives best case times
  770. for mul.w as 25 clocks best case/28 worst case, an '000 gives 70 clocks
  771. max, an '010 40 clocks, I can't find my '030/'040 manuals but you get the
  772. idea .... 
  773.  
  774. Genericly on CPUs with a full barrel shifter asr/asl complete is a clock or
  775. two, on a CPU with a hardware multiplier (rather than a shift-and-add engine)
  776. the multiply will run in a couple of clocks.
  777.  
  778. The point I'm trying to make here is that this stuff isn't at all cut and dried,
  779. if you target a particular CPU in a particular memory sub-system you can
  780. make this trade off - your compiler probably can't for cases like the one above
  781. but probably can for more obvious cases like 3*x and 10*x and 15*x because it's
  782. targetted at the whole range of Macs - from 8MHz '000s up to 25/50MHz '040s,
  783. I'm pretty sure that when you tell MPW to make '020 code it doesn't know
  784. to tune like this, instead it just targets instructions that are not available
  785. on the 16-bit CPUs
  786.  
  787.     Paul Campbell
  788.     SuperMac
  789.  
  790. - -- 
  791. Paul Campbell    UUCP: ..!mtxinu!taniwha!paul     AppleLink: CAMPBELL.P
  792.  
  793.     "'Potato', not 'Potatoe'"
  794.         Bart Simpson - on the blackboard 6/25/92
  795.  
  796. +++++++++++++++++++++++++++
  797.  
  798. From: Bruce.Hoult@bbs.actrix.gen.nz
  799. Date: 3 Jul 92 08:51:59 GMT
  800. Organization: Actrix Information Exchange
  801.  
  802. In article <1138@taniwha.UUCP> paul@taniwha.UUCP (Paul Campbell) writes:
  803. > >Bruce.Hoult@bbs.actrix.gen.nz writes:
  804. > >The same thing applys to the multiply instruction. Suppose you want to
  805. > >multiply an unsigned integer by 100 (decimal) which is 1100100 in binary.
  806. > >You can use...
  807.  
  808. [my code that accidently multiplies by 52 instead of 100 deleted :-)  (I
  809. noticed 10 mins after I posted it and one person emailed me about it later,
  810. btw]
  811.  
  812. > But it takes 16 bytes of instructions compared with 4 bytes, the difference
  813. > is about a whole cache line, the extra time it takes to read this is about
  814. > ~60+3*40+100 (assuming worst case RAS precharge delays) = 280nS which on a
  815. > system with a 50MHz cpu core clock (ie a 50MHz '030 or 25MHz '040) is 14 clocks
  816. > which makes total execution time for the first case to be 46 clocks, if
  817. > it's not in the cache already (ie it's not in an inner loop) - still faster,
  818. > but maybe not worth the effort.
  819.  
  820. Uh, those numbers are explicitly 68000 timings, *not* anything with a cache.
  821.  
  822.  
  823. > It also depends on which CPU you use, my '020 manual gives best case times
  824. > for mul.w as 25 clocks best case/28 worst case, an '000 gives 70 clocks
  825. > max, an '010 40 clocks, I can't find my '030/'040 manuals but you get the
  826. > idea .... 
  827. > Genericly on CPUs with a full barrel shifter asr/asl complete is a clock or
  828. > two, on a CPU with a hardware multiplier (rather than a shift-and-add engine)
  829. > the multiply will run in a couple of clocks.
  830.  
  831. The point is that I find it interesting that on a machine with a shift-and-add
  832. microcode engine for multiply you can often beat it with macrocode.
  833.  
  834.  
  835. > The point I'm trying to make here is that this stuff isn't at all cut and dried,
  836. > if you target a particular CPU in a particular memory sub-system you can
  837. > make this trade off - your compiler probably can't for cases like the one above
  838. > but probably can for more obvious cases like 3*x and 10*x and 15*x because it's
  839. > targetted at the whole range of Macs - from 8MHz '000s up to 25/50MHz '040s,
  840.  
  841. I agree entirely.  I'm not suggesting this as a normal technique except in
  842. the most critical situations, and even there *test* it too see if it really
  843. is faster.  There can be quite an advantage on the 68000.  I haven't worked
  844. out the numbers, but I'd expect a somewhat smaller advantage on the
  845. '020 and '030.  I'd expect this sort of thing to be completely counter-
  846. productive on the '040.
  847.  
  848.  
  849. You might note that the original message I was replying to was talking about
  850. how bad the VAX 11/780 was because you could often beat the more complex
  851. instructions with a sequence of simpler ones.
  852.  
  853. I'm merely pointing out that the VAX is not alone in this and other
  854. CPU's of the same time period are similar.  That's what prompted the
  855. so called "RISC" techniques in the first place, and what led to even
  856. CISC CPUs such as the 68040 and 80486 and recent VAXes getting large
  857. performance improvements without increasing clock rates.
  858. - -- 
  859. Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 477 2116
  860. BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
  861. "Cray's producing a 200 MIPS personal computer with 64MB RAM and a 1 GB
  862. hard disk that fits in your pocket!"   "Great!  Is it PC compatable?"
  863.  
  864. +++++++++++++++++++++++++++
  865.  
  866. From: bayes@hplvec.LVLD.HP.COM (Scott Bayes)
  867. Date: 9 Jul 92 23:37:23 GMT
  868. Organization: Hewlett-Packard Co., Loveland, CO
  869.  
  870. On a 68040 we came up with a very nearly optimum block move; that is not
  871. a guess, but a fact, as we had an HP 16500 analyzer on the bus, and
  872. could see that we were executing no-wait state moves of a large amount
  873. of data, maybe even a full scanline of the CRT (I can't remember) before
  874. overhead (non-data-move cycles) appeared.  The overhead was required to
  875. move pointers, etc.  Implementation was in assembly; I don't think
  876. there's any compiler written that could have come up with this one!
  877.  
  878. Granted it was a very special case.
  879.  
  880. The scanline is 1024 bytes wide, and the code had to scroll up or down
  881. by one character cell height.  It is cache-line aligned (i.e.  left edge
  882. of the framebuf starts on a cache-line boundary).  The frame buffer RAM
  883. is 0 wait state for both read and write, and supports block (?  I think
  884. that's the term) mode access:  viz.  accessing a single address loads
  885. the whole cache line surrounding the address.  Copyback caching is
  886. obviously enabled.  The bus is 32/32 at 80nsec.  It ain't a Mac.
  887.  
  888. The technique was to
  889.  
  890.     read a single longword at each successive 16 byte address in
  891.     unrolled loop.  This caused the whole cacheline to be loaded
  892.     into D-cache, even though the processer thought it was only
  893.     loading 1/4 line. we could not move16 it, because we were
  894.     moving it to D0 all the time
  895.  
  896.     Move16 the from source to destination addresses in unrolled loop
  897.  
  898. Loops were unrolled out to the point where the whole loop to handle a
  899. scanline plus the code to bump pointers and the outer loop just fit into
  900. I-cache.  This eliminated most inner-loop overhead, 'cause the inner
  901. loop only executed once or twice as I remember.  After the first scan
  902. line had been moved, all code was in I-cache and the rest of the scroll
  903. burned rubber.
  904.  
  905. the code sort of looked like this:
  906.  
  907.     <unlock D-cache>
  908.     move.l    (a0),d0
  909.     adda.l  #16,a0    skip to next cacheline
  910.     <repeat above unrolled enough to cram I-cache>
  911.  
  912. then reset aregs and
  913.  
  914.     <lock D-cache>
  915.     move16  (a0)+,(a1)+
  916.     <unrolled>
  917.  
  918. the move16s sourced from cache, so there were only writes on the bus
  919. in the second loop.
  920.  
  921. The memory controller worked most efficiently when I/O direction didn't
  922. change, so it was best to do all cacheloads separately from the flush.
  923.  
  924. On the analyzer we saw hundreds of inbound memory cycles at maximum bus
  925. speed, a short gap as the pointers were reset, then the same number of
  926. outbound cycles at max bus speed, then another short gap, and repeat for
  927. the next chunk.  Throughput was about 45MB/sec over the whole routine
  928. compared to a theoretical max for the bus of 50MB/sec.
  929.  
  930. But the weird things were that crazy first loop, and seeing the analyzer
  931. show very long strings of uninterrupted I/O at max rate.
  932.  
  933. The algorithm served its purpose extremely well, and the hand-tuning was
  934. justified (no arguments entertained on that last point!  and no flames
  935. on coding practices, either--mamagement demanded maximum performance from
  936. inadequate H/W)
  937.  
  938. +++++++++++++++++++++++++++
  939.  
  940. From: bayes@hplvec.LVLD.HP.COM (Scott Bayes)
  941. Date: Wed, 15 Jul 1992 21:05:29 GMT
  942. Organization: Hewlett-Packard Co., Loveland, CO
  943.  
  944. In general I agree with:
  945.  
  946. > you have to work hard to do the job... :-)  BTW, I'm not management, but I
  947. > have a definite leaning towards maximally efficient use of modest hardware.
  948. > Hardware costs are per-unit, but development costs can be amortized
  949. > nicely over the entire product life.  If your instrument ends up costing
  950. > several hundred dollars than your competitor's RISC-y business, but is
  951. > equivalent in function and performance guess who wins?
  952.  
  953. but the H/W Lab published figures that showed we could get better
  954. performance than we actually attained, without these "heroic" coding
  955. measures. Too late, we discovered: "NOT!". So the project was delayed
  956. while we tuned this up, which cost $. The same display was to be
  957. available on an '030 machine in the family. Because the performance
  958. was not acceptable, that configuration is not being sold, though we
  959. feel it would have been saleable, modulo performance. More $.
  960.  
  961. Finally, as things got desperate, the H/W lab started proposing things
  962. like "we'll hack up a H/W mover for you for only a few $100000 cost in
  963. design, board layout, tooling, etc. Oh, and an extra $25/board."
  964.  
  965. I'm used to squeezing performance out of H/W. At some point we reach
  966. a crossover of per unit cost vs sum(development cost, delay opportunity
  967. cost). I couldn't say exactly where we came out in the case cited.
  968.  
  969. ScottB
  970.  
  971. +++++++++++++++++++++++++++
  972.  
  973. From: bayes@hplvec.LVLD.HP.COM (Scott Bayes)
  974. Date: Wed, 15 Jul 1992 21:11:02 GMT
  975. Organization: Hewlett-Packard Co., Loveland, CO
  976.  
  977. One last point on clever coding.
  978.  
  979. Sales lifetimes of computing systems are decreasing.  We have had quite
  980. a few systems lately whose sales lives are measured in months, rather
  981. than years.  The break-even comes more and more onto the side of
  982. "develop quickly and cheaply" in that situation.  As technology advances
  983. at more and more rapid rates in our field (at least, so I believe), the
  984. balance moves farther andf farther in that direction.  The schedule
  985. pressure on my project was immense, and quality suffered elsewhere, when
  986. programmers were putting in 16 hour days for months:  you get too worn
  987. down to do a good job.
  988.  
  989. ScottB
  990.  
  991. ---------------------------
  992.  
  993. From: kishon-amir@CS.YALE.EDU (amir kishon)
  994. Subject: List Manager help sought
  995. Organization: Yale University Computer Science Dept., New Haven, CT 06520-2158
  996. Date: Tue, 14 Jul 1992 02:36:55 GMT
  997.  
  998. I would like to use the List Manager to implement a table of 3
  999. columns. The only thing different about this table is that when I
  1000. click on a cell I would like to highlight the whole row which this
  1001. cell belongs to (rather than just highlighting the particular cell).
  1002.  
  1003. For example:
  1004.  
  1005. A1 A2 A3
  1006. B1 B2 B3
  1007. C1 C2 C3
  1008.  
  1009. if I click on either B1 B2 or B3 I would like B1 B2 and B3 to be
  1010. highlighted.
  1011.  
  1012. Unfortunately, the List Manager only highlights one cell given a mouse
  1013. click. Any help would be much appreciated.
  1014.  
  1015. - -Amir
  1016. - -- 
  1017. Amir Kishon                                 ARPA:   kishon-amir@cs.yale.edu
  1018. Yale University, Computer Science Dept.             kishon-amir@yale.arpa
  1019. P.O.Box 2158 Yale Station                   BITNET: kishon-amir@yalecs.bitnet
  1020. New Haven, CT. 06520-2158                   UUCP:   decvax!yale!kishon-amir
  1021.  
  1022. +++++++++++++++++++++++++++
  1023.  
  1024. From: dave@gergo.tamu.edu (Dave Martin)
  1025. Date: 14 Jul 92 12:53:00 GMT
  1026. Organization: Geochemical & Environmental Research Group, Texas A&M University
  1027.  
  1028. In article <1992Jul14.023655.8607@cs.yale.edu>, kishon-amir@CS.YALE.EDU (amir kishon) writes...
  1029. >I would like to use the List Manager to implement a table of 3
  1030. >columns. The only thing different about this table is that when I
  1031. >click on a cell I would like to highlight the whole row which this
  1032. >cell belongs to (rather than just highlighting the particular cell).
  1033. >if I click on either B1 B2 or B3 I would like B1 B2 and B3 to be
  1034. >highlighted.
  1035. >Unfortunately, the List Manager only highlights one cell given a mouse
  1036. >click. Any help would be much appreciated.
  1037.  
  1038. What you could do is -- each time there is a mousedown event and it is in the
  1039. list area -- get the selected cell then do a LSetSelect(true,...) on the other
  1040. cells in that row. That should work (I think).
  1041.  
  1042.  -                                                                     -
  1043.  - Dave Martin - Geochemical & Environmental Research Group, Texas A&M - 
  1044.  - DAVE@GERGA[GERGO,GERGI].TAMU.EDU - BROOKS@TAMVXOCN.BITNET - AOL:DBM -
  1045.  -                                                                     -
  1046.  
  1047. +++++++++++++++++++++++++++
  1048.  
  1049. From: Jerome Chan <yjc@po.cwru.edu>
  1050. Organization: Alethea, The Twilight World!
  1051. Date: Tue, 14 Jul 92 14:18:36 GMT
  1052.  
  1053. In article <14JUL199206531047@gergo.tamu.edu> Dave Martin,
  1054. dave@gergo.tamu.edu writes:
  1055. >>I would like to use the List Manager to implement a table of 3
  1056.  
  1057.   If I use ResEdit and copy another LDEF from another application and put
  1058. it into mine, would I be able to use it if I pass the correct the resouce
  1059. ID as theProc in LNew(...)? Would it respond as the built-in LDEF?
  1060.  
  1061. - --NewBie Programmer At Work--
  1062. - --Day 2 and still going--
  1063.  
  1064. - ---
  1065.  Fading
  1066.  
  1067. +++++++++++++++++++++++++++
  1068.  
  1069. From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
  1070. Date: 14 Jul 92 17:22:48 GMT
  1071. Organization: Purdue University
  1072.  
  1073. In article <1992Jul14.141836.1165@usenet.ins.cwru.edu> yjc@po.cwru.edu (Jerome Chan) writes:
  1074. >
  1075. >  If I use ResEdit and copy another LDEF from another application and put
  1076. >it into mine, would I be able to use it if I pass the correct the resouce
  1077. >ID as theProc in LNew(...)? Would it respond as the built-in LDEF?
  1078.  
  1079. Only if you know the data format for the cells. For example in some of
  1080. my LDEF's I just place a pointer or handle in the cell, the LDEF then
  1081. knows what to do with the pointer or handle. An LDEF that displays icons
  1082. may take just the icon id or the actual icon data itself, unless you know
  1083. what to put in the cell, it is unlikely that you will be able to use another
  1084. persons LDEF.
  1085.  
  1086. Just as an aside, LDEF's are probably the easiest of all the xDEFs to write
  1087. They are very straightforward. I know that the second edition of Macintosh
  1088. Programming Secrets has an example you can look at. 
  1089.  
  1090. carl
  1091.  
  1092. - --
  1093. Carl W. Haynes III  
  1094. Haynes Consulting Services        ||  CWH3@aol.com
  1095. PO Box 2715                       ||  haynes@mace.cc.purdue.edu
  1096. W. Lafayette, IN 47906            ||  voice: 317 463-6383
  1097. - ----------------------------------------------------------------------
  1098. Macintosh Programming & Consulting --- currently seeking contract work
  1099.  
  1100. +++++++++++++++++++++++++++
  1101.  
  1102. From: stoodt@cis.umassd.edu (Michael Stoodt)
  1103. Date: 14 Jul 92 20:17:45 GMT
  1104. Organization: University of Massachusetts Dartmouth
  1105.  
  1106. In <1992Jul14.023655.8607@cs.yale.edu> kishon-amir@CS.YALE.EDU (amir kishon) writes:
  1107.  
  1108. >I would like to use the List Manager to implement a table of 3
  1109. >columns. The only thing different about this table is that when I
  1110. >click on a cell I would like to highlight the whole row which this
  1111. >cell belongs to (rather than just highlighting the particular cell).
  1112.  
  1113. >Unfortunately, the List Manager only highlights one cell given a mouse
  1114. >click. Any help would be much appreciated.
  1115.  
  1116. Don't make it a table of three columns;  make it a table of one column
  1117. whose List DEFinition Draw() routine is smart enough to draw the three
  1118. pieces of data at positions to make them line up in columns.
  1119.  
  1120. +++++++++++++++++++++++++++
  1121.  
  1122. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  1123. Organization: NCRPDA, Curtin University
  1124. Date: Thu, 16 Jul 1992 05:12:40 GMT
  1125.  
  1126. In article <54005@mentor.cc.purdue.edu>, haynes@mace.cc.purdue.edu (Carl W.
  1127. Haynes III) wrote:
  1128. > In article <1992Jul14.141836.1165@usenet.ins.cwru.edu> yjc@po.cwru.edu (Jerome Chan) writes:
  1129. > >
  1130. > >  If I use ResEdit and copy another LDEF from another application and put
  1131. > >it into mine, would I be able to use it if I pass the correct the resouce
  1132. > >ID as theProc in LNew(...)? Would it respond as the built-in LDEF?
  1133.  
  1134. > Just as an aside, LDEF's are probably the easiest of all the xDEFs to write
  1135. > They are very straightforward. I know that the second edition of Macintosh
  1136. > Programming Secrets has an example you can look at. 
  1137.  
  1138. This is very true, plus there are lots of sample codes around - send a note
  1139. to stevej@ais.org (SteveJ) of TopSoft (makers of Free Software - but who
  1140. haven't quite figured out their motto yet :) and he can put you on to our
  1141. archive of source code, which has several ldefs buried in there somewhere.
  1142.  
  1143. BTW, another aside, coping an LDEF out of another application would be a
  1144. breach of copyright, probably even if you just use it for yourself, but
  1145. definitely otherwise - certainly it wouldn't be nice to do it without the
  1146. author's permision.  
  1147.  
  1148. Oh yeah, if you want a pascal source you could grab my source code for Talk
  1149. (I think its still at sumex-aim.stanford.edu in the /info-mac/source/pascal
  1150. directory, but they seem to be expiring files quickly these days...) which
  1151. has an LDEF that does pretty small icons and everything :-)  And if you ask
  1152. me, you can even use it :-)  Heck, you can use it even if you don't ask me,
  1153. as long as its not a commercial program :)
  1154.  
  1155. Have fun,
  1156.    Peter.
  1157.  
  1158. _______________________________________________________________________
  1159. Peter N Lewis, NCRPDA, Curtin University       peter@cujo.curtin.edu.au
  1160. GPO Box U1987, Perth WA 6001, AUSTRALIA             FAX: +61 9 367 8141
  1161.  
  1162. +++++++++++++++++++++++++++
  1163.  
  1164. From: oster@well.sf.ca.us (David Phillip Oster)
  1165. Organization: Whole Earth 'Lectronic Link
  1166. Date: Thu, 16 Jul 1992 06:14:24 GMT
  1167.  
  1168. In article <14JUL199206531047@gergo.tamu.edu> dave@gergo.tamu.edu (Dave Martin) writes:
  1169. _>In article <1992Jul14.023655.8607@cs.yale.edu>, kishon-amir@CS.YALE.EDU (amir kishon) writes...
  1170. _>>I would like to use the List Manager to implement a table of 3
  1171. _>>columns. The only thing different about this table is that when I
  1172. _>>click on a cell I would like to highlight the whole row which this
  1173. _>>cell belongs to (rather than just highlighting the particular cell).
  1174. _>>if I click on either B1 B2 or B3 I would like B1 B2 and B3 to be
  1175. _>>highlighted.
  1176.  
  1177. _>What you could do is -- each time there is a mousedown event and it is in the
  1178. _>list area -- get the selected cell then do a LSetSelect(true,...) on the other
  1179. _>cells in that row. That should work (I think).
  1180.  
  1181. Unfortunately, if the user clicks and drags, the LSetSelect() routine won't
  1182. be called until the user lets go of the mouse, so the user won't see the
  1183. correct hiliting behavior.
  1184.  
  1185. A better solution is a custom LDEF.  These are really simple to write.
  1186. You start be declaring a procedure in your application program like this:
  1187. (This comes from my Address Book Plus, available at any Macintosh software
  1188. store.)
  1189.  
  1190. /* VectorLDef - map the names of named vectors to an ldef
  1191.  */
  1192. pascal void VectorLDef(
  1193.     Integer mesg, Boolean hilit, 
  1194.     Rect *lrect, Cell lcell, Integer offset, Integer len, ListHandle list){
  1195.  
  1196.     Vector    v;
  1197.     NamedField    nf;
  1198.     Ptr        p;
  1199.     SignedByte    state;
  1200.  
  1201.     switch(mesg){
  1202.     case lDrawMsg:
  1203.     if( NIL == (v = (Vector) (**list).refCon) ||
  1204.         NIL == (nf = (NamedField) TGet(v, lcell.v))){
  1205.         return;
  1206.     }
  1207.     state = HSetLockState((Handle) nf);
  1208.     p = (Ptr) ((**nf).nameOffset + (Ptr) *nf);
  1209.     DrawNormalItem(lrect, Length(p), &p[1]);
  1210.     HSetState((Handle) nf, state);
  1211.     if(hilit){
  1212.         HiliteRect(lrect);
  1213.     }
  1214.     break;
  1215.  
  1216.     case lHiliteMsg:    HiliteRect(lrect);            break;
  1217.     case lCloseMsg:    DisposHandle((**list).listDefProc);    break;
  1218.     }
  1219. }
  1220.  
  1221. the point is, the handler for the drawMsg just draws the three columns,
  1222. in your case.  HiliteRect() is a procedure of mine, like InvertRect(),
  1223. but it does the right thing on color displays. (See Inside Mac Vol 5 for
  1224. more info on hiliting in color.)
  1225.  
  1226. To connect it, you use this:
  1227.  
  1228. typedef void (*SubrPtr)();
  1229.  
  1230. /* a 68000 jump absolute instruction
  1231.  */
  1232. typedef struct{
  1233.     short    op;
  1234.     SubrPtr addr;
  1235. }JmpBuf, *JmpBufPtr, **JmpBufHandle;
  1236.  
  1237. #define JMPINSTRUCT 0x4EF9
  1238.  
  1239. /* InitOurLDef - set our LDef to a captive routine.
  1240.  */
  1241. void InitOurLDef(SubrPtr func, ListHandle list){
  1242.     JmpBufHandle    ourLDEF;
  1243.  
  1244.     ourLDEF = (JmpBufHandle) NewHandle(sizeof(JmpBuf));
  1245.     (**ourLDEF).op = JMPINSTRUCT;
  1246.     (**ourLDEF).addr = func;
  1247.     (**list).listDefProc = (Handle) ourLDEF;
  1248. }
  1249.  
  1250. The advantage of this technique is that your LDEF procedure has full
  1251. access to yor application's globals. Unlike a separately compiled LDEF
  1252. resource. Since the LDEF gets called with the Cell as one of the 
  1253. parameters, you can store the data in any convenient way, and never put
  1254. it into the ListHandle at all. This makes modifying the list run MUCH
  1255. faster than keeping the data in the listhandle. The same technique can be used
  1256. with and <arbitrary> code definition procedure, but you have to worry about
  1257. setting up register A5 for WDEFs, and depending on what crazy third party 
  1258. software the users have, possibly CDEFs and MDEFs ttoo.
  1259.  
  1260. ---------------------------
  1261.  
  1262. End of C.S.M.P. Digest
  1263. **********************
  1264.